import { IUser } from '@model/user';
import { Injectable } from '@angular/core';
import { ApiService } from '@core/net/api.service';

@Injectable({
	providedIn: 'root'
})
export class UserService {

	constructor(
		private apiService: ApiService
	) { }
	/**
	 * 获取用户列表
	 * @returns
	 */
	getUserList(params: {
		page: number,
		size: number,
		[key: string]: any
	}): Promise<{ content: Array<IUser>, totalElements: number }> {
		params.page = params.page - 1;
		return this.apiService.get('/user/get', params);
	}

	/**
	 * 获取所有用户
	 * @returns
	 */
	getUserAll(): Promise<Array<any>> {
		return this.apiService.get('/user/getAll');
	}
	/**
	 * 新增用户
	 * @param body 
	 * @returns 
	 */
	addUser(body: IUser) {
		return this.apiService.post('/user/add', body);
	}
	/**
	 * 修改用户信息
	 * @param body 
	 * @returns 
	 */
	modifyUser(body: IUser) {
		return this.apiService.post('/user/modify', body);
	}
	/**
	 * 批量修改用户信息
	 * @param body
	 * @returns 
	 */
	modifyBatchUser(body: IUser) {
		return this.apiService.post('/user/modifyBatch', body);
	}


	/**
	 * 获取用户信息
	 * @param userCode
	 * @returns
	 */
	checkUser(userCode: string) {
		return this.apiService.get('/user/check?userCode='+ userCode);
	}


}
